import { Link, Routes, Route, Outlet } from "react-router-dom";
const Home0 = () => {
  return <div>home0页面</div>;
};
const Home111 = () => {
  return <div>home111页面</div>;
};
const Home1 = () => {
  return (
    <div>
      home1页面 - <Outlet />
    </div>
  );
};
const Home2 = () => {
  return <div>home2页面</div>;
};

const Home = () => {
  return (
    <>
      <div>home页面</div>
      <ul>
        <li>
          <Link to="/home/home1">home1</Link>
        </li>
        <li>
          <Link to="/home/home2">home2</Link>
        </li>
      </ul>

      <hr />

      {/* 相当于之前props.children */}
      <Outlet />
    </>
  );
};

const About = () => {
  return <div>about页面</div>;
};

const App = () => {
  return (
    <>
      <h3>router-v6-nest</h3>
      <ul>
        <li>
          <Link to="/home">home</Link>
        </li>
        <li>
          <Link to="/about">about</Link>
        </li>
      </ul>

      <hr />
      <Routes>
        {/* 可以直接嵌套，方便路由在一处进行渲染 */}
        <Route path="/home" element={<Home />}>
          {/* index表示子路由的路径和上一级的路径是相同的 */}
          <Route index element={<Home0 />}></Route>
          <Route path="/home/home1" element={<Home1 />}>
            <Route index element={<Home111 />}></Route>
          </Route>
          <Route path="/home/home2" element={<Home2 />}></Route>
        </Route>
        <Route path="/about" element={<About />}></Route>
      </Routes>
    </>
  );
};

export default App;
